package edu.sctu.xiangkun.day201505.day20150526.textfive;

import java.util.Collections;
import java.util.Hashtable;

/**
 * Created by lenovo on 2015/5/26.
 */
public class HashTableDemo {
    public void hashTable() {
        Hashtable hashtable = new Hashtable();
        for (int i = 0; i < 10; i++) {
            hashtable.put(new Integer(i), "集合值" + i);
        }
        hashtable.put(new Integer(10), "集合值 10");
        System.out.println("集合类的总数 = " + hashtable.size());
        System.out.println("集合的标识元素的集合 = " + Collections.list(hashtable.keys()));
        System.out.println("集合的值元素集合 = "+hashtable.values());

        if (hashtable.containsKey(new Integer(9))) {
            System.out.println("标识是9的值元素 = "+hashtable.get(new Integer(9)));
        }

        if(hashtable.containsValue("集合值 10")){
            System.out.println("值=\"集合值10\"的元素存在。");
        }
    }
    public void hashTableOne(){

        Hashtable<String,Integer> hashtable = new Hashtable<String,Integer>();
        hashtable.put("张三", 89);
        hashtable.put("李四",79);
        hashtable.put("王二",69);
        hashtable.put("鲁智深",88);
        hashtable.put("张飞",76);

        for(int j=0;j<hashtable.size();j++){
            System.out.printf("信息：%d%n", hashtable.get(j));
        }
    }
}
